package com.yonyou.crm.sys.repair.ctrl;



import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;
import com.yonyou.crm.common.exception.CrmMessageException;
import com.yonyou.crm.common.rest.util.RequestUtil;
import com.yonyou.crm.sys.repair.entity.RepairVO;
import com.yonyou.crm.sys.repair.rmitf.IRepairRmService;


@RestController
@RequestMapping(value = "/sys/repair")
public class RepairCtrl{
	@Autowired
	private IRepairRmService repairService;
	@RequestMapping(value = "{id}",method = RequestMethod.GET)
	public Object getById(@PathVariable("id") Long id,HttpServletRequest request, HttpServletResponse response) throws CrmMessageException {
		return repairService.idGetRepair(id);
	}
	
	/**
	 * 新增用户
	 * @param request
	 * @param response
	 * @return
	 */
	@RequestMapping(method = RequestMethod.POST)
	public Object insert(HttpServletRequest request, HttpServletResponse response) throws CrmMessageException {
		RepairVO vo = RequestUtil.getVO(request, RepairVO.class);
		vo=repairService.insertRepair(vo);
		return vo;
	}
	
	/**
	 * 修改用户
	 * @param request
	 * @param response
	 * @return
	 */
	@RequestMapping( method = RequestMethod.PUT)
	public Object update( HttpServletRequest request, HttpServletResponse response) throws CrmMessageException {
		RepairVO vo = RequestUtil.getVO(request, RepairVO.class);
		vo=repairService.updateRepair(vo);
		return vo;
	}
}
